/***************************************************************************  
 *	Project: empego-zkcdi-testapp
 *	Created: 30.10.2011, 21:58:48
 *	File: CdiTestComposer.java
 *	Package: net.empego.testwebapp
 * 
 *  $Id: CdiTestComposer.java 33 2011-12-14 22:32:20Z oberinspector@gmail.com $ 
 * 
 *
 * 	Copyright (C) 2011 empego.net. All Rights Reserved.
 *
 *
 *	This program is distributed under LGPL Version 3.0.
 *  See the LICENSE at http://www.gnu.org/licenses/lgpl-3.0.html
 *  I hope it will be useful, but WITHOUT ANY WARRANTY.
 *
 ***************************************************************************/
package net.empego.testwebapp;

import java.io.Serializable;
import java.util.List;

import javax.inject.Inject;

import net.empego.db.SiteMapDAO;
import net.empego.db.SiteMapEntryDO;
import net.empego.zkcdi.event.ObservesZkEvent;
import net.empego.zkcdi.util.ZkCdiEventHandlerComposer;

import org.zkoss.zk.ui.event.MouseEvent;

/**
 * The Class CdiTestComposer is a ZK-composer to demonstrate basic CDI features of empego-zkcdi.
 * 
 * @author <a href="mailto:thomas.mueller@empego.net">Thomas Müller</a>
 */
public class CdiSiteMapComposer extends ZkCdiEventHandlerComposer implements Serializable {

	private static final long serialVersionUID = -780924738611367996L;

	@Inject
	private SiteMapDAO siteMapDao;

	// @Inject
	// SiteMapWebDAO siteMapWebDao;

	private SiteMapEntryDO sitemaproot;

	public void createSiteMap(@ObservesZkEvent("createSiteMapBtn.onClick") final MouseEvent evt) {
		siteMapDao.createSiteMap(5, 5, "Menu", "ROOT");
		int i = 0;
		i++;
	}

	public void loadSiteMap(@ObservesZkEvent("loadSiteMapBtn.onClick") final MouseEvent evt) {
		sitemaproot = siteMapDao.findSiteMap("ROOT");
		if (sitemaproot == null) {
			return;
		}

		final List<SiteMapEntryDO> children = sitemaproot.getChildren();
		for (final SiteMapEntryDO siteMapEntryDO : children) {
			final String label = siteMapEntryDO.getLabel();
		}
	}

}
